<?php
class ModelLocalisationZone extends Model {
	public function getZonesByCountryId($country_id) {
		$zone_data = $this->cache->get('zone.' . $country_id);
		if (!$zone_data) {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '" . (int)$country_id . "' ORDER BY zone_id ASC ");
			$zone_data = $query->rows;
			if(empty($zone_data) == false){
				if(isset($zone_data[28])){
					unset($zone_data[28]);
				}
				if(isset($zone_data[0])){
					unset($zone_data[0]);
				}
				if(isset($zone_data[32])){
					unset($zone_data[32]);
				}

				$arr0 = array("zone_id" => 3750,
							  "country_id"=>230,
							  "code"=> "ALL",
							  "name" => "Toan Quoc");
				$arr1 = array("zone_id" => 3780,
							  "country_id"=>230,
							  "code"=> "HC",
							  "name" => "Ho Chi Minh City");
				$arr2 = array("zone_id" => 3776,
							  "country_id"=>230,
							  "code"=> "HI",
							  "name" => "Ha Noi");
				$zone_data = array_pad($zone_data, - count($zone_data) -1 ,$arr2);
				$zone_data = array_pad($zone_data, - count($zone_data) -1 ,$arr1);
				$zone_data = array_pad($zone_data, - count($zone_data) -1 ,$arr0);
			}
			$this->cache->set('zone.' . $country_id, $zone_data);
		}
		return $zone_data;
	}
}
?>